package lpl.com.xyd.test.manage.common.utils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 *  EXCEL 导入表头枚举
 * @Author mingliang
 * @Date 2017-12-27 16:12
 */
public enum ExcelTitleEnum {

    NO("no","编号","String"),
    NAME("name","需求名称","String"),
    STATUS("status","需求状态","String"),
    TRANS_CONTRACT_EFFECT_TIME("pm","PM","String"),
    NOTICE("notice","PM是否同步通知","String"),
    DEV("dev","DEV","String"),
    QA("qa","QA","String"),
    GROUP("group","所属开发组/项目","String"),
    CASENO("caseNo","用例数","String"),
    DEFECTNO("defectNo","缺陷数","String"),
    DEFECTRATE("defectRate","缺陷率","String"),
    REMARKS("remarks","备注","String"),
    WEEK_NO("weekno","周报NO","String"),
    WEEK("week","周报","String")
    ;

    private String code;
    private String message;
    private String type;

    ExcelTitleEnum(String code, String message,String type) {
        this.code = code;
        this.message = message;
        this.type = type;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public static List<String> getTitle(){
        List<String> tilte = new ArrayList<>();
        List<ExcelTitleEnum> _enumList = getAll();
        _enumList.forEach(v->{
            if (!v.getMessage().equals(WEEK.message) && !v.getMessage().equals(WEEK_NO.message)){
                tilte.add(v.getMessage());
            }
        });
       return tilte;
    }

    /**
     *  根据code获取枚举描述
     * @param code
     * @return
     */
    public static String getMsgByCode(String code){
        List<ExcelTitleEnum> _enumList = getAll();
        for (ExcelTitleEnum _enum : _enumList){
            if (_enum.getCode().equals(code)){
                return _enum.getMessage();
            }
        }
        return null;
    }

    /**
     * 根据code获取枚举类
     * @param code
     * @return
     */
    public static ExcelTitleEnum getByCode(String code){
        List<ExcelTitleEnum> errorcedeEnumList = getAll();
        for (ExcelTitleEnum _enum : errorcedeEnumList){
            if (_enum.getCode().equals(code)){
                return _enum;
            }
        }
        return null;
    }

    /**
     * 根据code获取枚举类
     * @param message
     * @return
     */
    public static ExcelTitleEnum getByMessage(String message){
        List<ExcelTitleEnum> errorcedeEnumList = getAll();
        for (ExcelTitleEnum _enum : errorcedeEnumList){
            if (_enum.getMessage().equals(message)){
                return _enum;
            }
        }
        return null;
    }


    public static String getCodeByMessage(String message){
        List<ExcelTitleEnum> errorcedeEnumList = getAll();
        for (ExcelTitleEnum _enum : errorcedeEnumList){
            if (_enum.getMessage().equals(message)){
                return _enum.getCode();
            }
        }
        return null;
    }
    /**
     * 获取所有枚举
     * @return
     */
    public static List<ExcelTitleEnum> getAll(){
        return Arrays.asList(ExcelTitleEnum.values());
    }

}
